package zhongbo.java.air.airflightpath.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;
import zhongbo.java.air.airflightpath.config.RedisListenerConfig;

/*
接收订阅频道log_cannel广播的消息 */
@Component
@Slf4j
//监听redis频道中的消息
public class RedisSubscribeLogChanelListener implements MessageListener {


    @Override
    //pattern匹配模式为订阅模式，message有效
    public void onMessage(Message message, byte[] pattern) {
        //接收到的message对象的字节数组--转字符串
  String msg= new String(message.getBody());
    log.info("收到订阅频道广播发送消息",msg);//记录日志
        System.out.println("收到日志"+msg);//打印消息
    }
}
